import { Entity, PrimaryUuid, Unique, CreateDate, UpdateDate, DateTime, Openid, Ip, Token, TokenStatus, Uuid, Jsonb } from '@sker/core'
@Entity({ name: 'wx_token' })
@Unique('UK_WX_REFRESH_TOKEN', ['refresh_token'])
export class WxToken {
    static title: string = `登录凭证`;
    static resource: string = `wx_token`;

    @PrimaryUuid({
        primaryKeyConstraintName: 'PK_WX_TOKEN_ID'
    })
    id!: string;

    @Openid()
    openid!: string;

    @Uuid({ nullable: true })
    member_id: string;

    @Ip({ comment: 'ip地址' })
    ip!: string;

    @TokenStatus({ comment: '状态' })
    status!: string;

    @Token({
        comment: '登录凭证'
    })
    token!: string;

    @Token({
        comment: '刷新凭证'
    })
    refresh_token!: string;

    @DateTime({ comment: '登录凭证过期时间' })
    expires_in!: Date;

    @DateTime({ comment: '刷新凭证过期时间' })
    refresh_token_expires_in!: Date;

    @CreateDate({ comment: '登录时间' })
    login_date!: Date;

    @UpdateDate({ comment: '更新时间' })
    update_date!: Date;

    @Jsonb({ nullable: true })
    session: any;
}